home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 03 Pathfinding with Astar / 04 Higgins / Listing6.cpp < prev   
Encoding:
Text File  |  2001-12-09  |  1.3 KB  |  32 lines

  1. /* Copyright (C) Dan Higgins, 2001. 
  2.  * All rights reserved worldwide.
  3.  *
  4.  * This software is provided "as is" without express or implied
  5.  * warranties. You may freely copy and compile this source into
  6.  * applications you distribute provided that the copyright text
  7.  * below is included in the resulting source code, for example:
  8.  * "Portions Copyright (C) Dan Higgins, 2001"
  9.  */
  10.  
  11. // Excerpt from FastStorage's ResetPathfinder method: 
  12. // (Note: 1. theBox is a 2D integer rectangle that represents 
  13. // the bounds of what we searched LAST path with this pathfinder. 
  14. // In a sense, what is DIRTY. 2. theBoxes' Left is the lowest X 
  15. // and Top returns is the lowest Y coordinate. 3. theBoxes' Right 
  16. // is the highest X and Bottom is the highest Y.) 
  17.  
  18. // Get the X offset where we will begin to memset from.
  19. theXOffset = ((theBox.GetLeft() * mMaxX)+ theBox.GetTop());
  20.  
  21. // Get the amount we will need to clear.
  22. theAmountToClear = (((theBox.GetRight() * mMaxX) +
  23.                       theBox.GetBottom()) - theXOffset);
  24.  
  25. // memset NODE array using the Xoffset and AmountToClear
  26. ::memset(this->mNodes + theXOffset, NULL,
  27.          theAmountToClear * sizeof(AStarNode*));
  28.  
  29. // Reset the flags array using the same dirty rectangle
  30. ::memset(this->mFlags + theXOffset, kClear,
  31.          theAmountToClear * sizeof(AStarNodeStatusFlags));
  32.